<template>
	<view class="main">
		<u-navbar title="注销账号" :autoBack="true" :placeholder="true" :titleStyle="state.titleStyle" :height="40"
			bgColor="#F5F5F5">
		</u-navbar>
		<view class="buc">
			在开始注销前，请确认以下内容：
		</view>
		<view class="buc lans" >
			·账号将不可找回
		</view>
		<view class="hao">
			·账号注销后，账号绑定手机等相关信息将被释放，账号将无法登录。
		</view>
		<view class="agreement">
			<view class="chose" @click="state.chosed=!state.chosed">
				<image
					:src="state.chosed?'../../static/icon_select2@2x.png':'../../static/icon_select@2x.png'"
					mode=""></image>
			</view>
			<text>我已阅读并同意<lable style="color: #1BDDD0;">《用户注销协议》</lable>
			</text>
		</view>
		<view class="butLi" @click="getZhu" >
		    确认注销
		</view>
		<!-- 注销成功 @click="state.zhuShow=true"-->
		<view class="duis" v-if="state.zhuShow">
			<view class="duihao">
				<image src="../../static/me_shezhi_icon_success@2x.png" mode=""></image>
			</view>
			<view class="zhu">
				注销成功
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
	} from 'vue';
	import sheep from '@/sheep';
	import {
		onLoad,
	} from '@dcloudio/uni-app';
	const state = reactive({
		 chosed: true ,//是否同意
		 zhuShow:false,//注销成功
	});
	onLoad((options) => {});
     function getZhu() {
		if (state.chosed == true) {
			uni.showModal({
				title: '退出',
				content:'确认要注销账号吗？',
				cancelText:'取消',
				confirmText:'确认',
				confirmColor:'#1BDDD0',
				cancelColor:'#999',
				success: function(res) {
					if (res.confirm) {
						getXiao()
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			})
		}else{
			uni.showToast({
			  title:'请阅读用户注册协议',
			  icon: "none",
			  duration: 1000,
			})
		}
	}
	async function getXiao(){
		const {code,data,msg} = await sheep.$api.user.cancleAcc({
			token:uni.getStorageSync('token'),
		})
		console.log(code,'code')
		if (code == 1) {
		   state.zhuShow=true
		}else{
			uni.showToast({
			  title:msg,
			  icon: "none",
			  duration: 1000,
			})
		}
	}
</script>
<style  lang="scss">
	.duis{
		width: 100%;
		height:100vh;
		background: #fff;
		text-align: center;
		position: fixed;
		top:100rpx;
		left:0;
		.duihao{
			margin-top: 80rpx;
		}
		image{
			width: 160rpx;
			height:160rpx;
		}
		.zhu{
			width: 100%;
			line-height: 80rpx;
			text-align: center;
		}
	}
	page {
		height: 100%;
		width: 100%;
		background-color: #fff;
		.main {
			height: 100%;
			width: 100%;
			background-color: #fff;
		}
		.dui{
		    width:calc(100% - 48rpx);
		    padding:24rpx;
		    background: #fff;
			margin: 20rpx 0; 
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			justify-content: space-between;
			input{
				text-align: right;
			}
		}
		.agreement {
			width:calc(100% - 48rpx);;
			display: flex;
			align-items: center;
			margin: auto;
		    font-size: 24rpx;
		    font-family: PingFang SC-Medium, PingFang SC;
		    font-weight: 500;
		    color: #999999;
			.chose {
				height: 32rpx;
				width: 32rpx;
		
				image {
					height: 32rpx;
					width: 32rpx;
				}
			}
		}
		.butLi{
			width: calc(100% - 64rpx);
			margin:60rpx auto;
			background: #F3F3F3;
			font-size:32rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			 /* font-weight: bold; */
			color: #999999;
			line-height: 92rpx;
			text-align: center;
			border-radius: 54rpx;
		}
		.buc{
			width:calc(100% - 64rpx);
			margin: 20rpx auto;
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		.lans{
			color: #1BDDD0;
		}
		.hao{
			width:calc(100% - 64rpx);
			margin: 20rpx auto;
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			color: #333333;
			font-weight: 0;
		}
		.duiHuan{
			width: calc(100% - 64rpx);
			margin:20rpx auto;
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #666666;
			line-height: 50rpx;
		}
   }
   
</style>
